<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<a href="http://api-test.foodie.vc/interface.php?ver=11&amp;mo=a2&amp;a=get_tj_export_to_excel&amp;shop_id=8">导出<</a>
		<script type="text/javascript">
			var imgsrc = 'https://yj-community.oss-cn-qingdao.aliyuncs.com/imgs/ck8BeJi3EEtFv6QhdCQaEn8gPYTwe2Nj.jpg';
//			var imgsrc = 'http://img1.imgtn.bdimg.com/it/u=3247749323,1379996244&fm=26&gp=0.jpg';
			function getUrlBase64(url, ext, callback) {
				var canvas = document.createElement("canvas"); //创建canvas DOM元素
				var ctx = canvas.getContext("2d");
				var img = new Image;
//				img.crossOrigin = 'Anonymous';
				img.src = url;
				img.onload = function() {
					canvas.height = 60; //指定画板的高度,自定义
					canvas.width = 85; //指定画板的宽度，自定义
					ctx.drawImage(img, 0, 0, 60, 85); //参数可自定义
					var dataURL = canvas.toDataURL("image/" + ext);
					callback.call(this, dataURL); //回掉函数获取Base64编码
					canvas = null;
				};
			}
			getUrlBase64(imgsrc, "jpg", function(base64) {
				console.log("base64", base64)
			})
		</script>

	</body>

</html>